#!/bin/sh

function gpio_id_str_to_num() {
	var=$1
	low_num=${var:0-1}
	high_c=${var:0:1}
	v=$((16#${high_c}-0xA))
	num=`expr $low_num + 8 \* $((v))`
	echo "$num"
}

dongle() {
	#### for module detect control
	oraygpio -H -G 3 -N $(gpio_id_str_to_num "C2")
	#### for 4g led
	oraygpio -H -G 3 -N $(gpio_id_str_to_num "C5")
}

led() {
	#指示灯 gpio 模式
	oraygpio -L -G 3 -N $(gpio_id_str_to_num "C0")
	oraygpio -L -G 3 -N $(gpio_id_str_to_num "B6")
	oraygpio -L -G 3 -N $(gpio_id_str_to_num "B4")
}

start() {
  	led
	dongle
}

stop() {
	return 0
}

case "$1" in
	start)
		start > /dev/null
		;;
	stop)
		stop
		;;
	restart | reload)
		stop
		start
		;;
	mcu)
		mcu
		;;
	led)
		led
		;;
	*)
		echo "Usage: $0 {start|stop|restart|mcu|led}"
		exit 1
		;;
esac

exit $?
